package appconfig

import (
	"github.com/spf13/viper"
	"go.uber.org/zap"
)

type ServerConfig struct {
	MysqlConfig MysqlConfig
	RedisConfig RedisConfig
}
type MysqlConfig struct {
	User     string
	Password string
	Host     string
	Port     int
	DbName   string
}

type RedisConfig struct {
	Host string
	Port int
}

var AppConf ServerConfig

func InitConfig() {
	viper.SetConfigFile("../order_srv/appconfig/dev.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		zap.S().Info(err)
	}
	err = viper.Unmarshal(&AppConf)
	if err != nil {
		zap.S().Info(err)
	}
}
